package vip.aster.common.constant.enums;

import lombok.Data;
import lombok.Getter;

/**
 * MenuTypeEnum
 *
 * @author Aster
 * @since 2024/1/19 15:15
 */
@Getter
public enum MenuTypeEnum {
    /**
     * 目录
     */
    DIRECTORY("0", "目录"),
    /**
     * 菜单
     */
    MENU("1", "菜单"),
    /**
     * 按钮
     */
    BUTTON("2", "按钮");


    private final String code;
    private final String text;

    MenuTypeEnum(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public static String getCode(String text) {
        MenuTypeEnum[] enums = MenuTypeEnum.values();
        for (MenuTypeEnum bEnum : enums) {
            if (bEnum.getText().equals(text)) {
                return bEnum.getCode();
            }
        }
        return null;
    }

    public static String getText(String code) {
        MenuTypeEnum[] enums = MenuTypeEnum.values();
        for (MenuTypeEnum bEnum : enums) {
            if (bEnum.getCode().equals(code)) {
                return bEnum.getText();
            }
        }
        return null;
    }
}
